Skip to content

Conversation

alltheseas
Copy link
Collaborator

Summary

-Added NIP-88 poll event kinds and a shared PollResultsStore, wiring poll support through DamusState, HeadlessDamusState, and the notification extension.

  • Introduced poll domain models (events, responses, drafts, vote builder) plus logic for sanitising votes, deduplicating by pubkey, and managing relay
    subscriptions.
  • Upgraded the composer with a dedicated poll UI, validation (no media/mentions, unique options, future expiry), relay tagging, and NIP-37 draft persistence
    for polls.
  • Rendered polls in the timeline via a new PollEventView, enabling voting, enforcing “vote after view,” and showing results only post-vote or expiry.
  • Localised new strings and added poll unit tests for event parsing and vote submission logic.

Checklist

  • I have read (or I am familiar with) the Contribution Guidelines
  • I have tested the changes in this PR
  • I have opened or referred to an existing github issue related to this change. Polls #401
  • My PR is either small, or I have split it into smaller logical commits that are easier to review
  • I have added the signoff line to all my commits. See Signing off your work
  • I have added appropriate changelog entries for the changes in this PR. See Adding changelog entries
    • I do not need to add a changelog entry. Reason: [Please provide a reason]
  • I have added appropriate Closes: or Fixes: tags in the commit messages wherever applicable, or made sure those are not needed. See Submitting patches

Test report

Please provide a test report for the changes in this PR. You can use the template below, but feel free to modify it as needed.

Device: [Please specify the device you used for testing]

iOS: [Please specify the iOS version you used for testing]

Damus: [Please specify the Damus version or commit hash you used for testing]

Setup: [Please provide a brief description of the setup you used for testing, if applicable]

Steps: [Please provide a list of steps you took to test the changes in this PR]

Results:

  • PASS
  • Partial PASS
    • Details: [Please provide details of the partial pass]

Other notes

[Please provide any other information that you think is relevant to this PR.]

@alltheseas
Copy link
Collaborator Author

note this is 100% pure vibe generated on a non-mac machine, and untested. will attempt testing now on xcode/macos

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements NIP-88 polls support in Damus, adding comprehensive poll functionality including creation, voting, and results display. The implementation introduces domain models for polls, a shared store for managing poll state, and integrates polling capabilities throughout the app.

  • Introduces poll domain models (PollEvent, PollResponse, PollDraft) and supporting infrastructure
  • Adds a PollResultsStore for managing poll state and vote submission with relay subscriptions
  • Integrates poll UI components in the composer and timeline with validation and voting functionality

Reviewed Changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
damusTests/PollTests.swift Adds unit tests for poll event parsing and vote submission logic
damusTests/Mocking/MockDamusState.swift Updates mock state to include poll store
damus/TestData.swift Updates test data to include poll store
damus/Shared/Utilities/HeadlessDamusState.swift Adds polls property to headless state protocol
damus/Features/Timeline/Models/HomeModel.swift Adds poll event handling and subscription filters
damus/Features/Posting/Views/PostView.swift Integrates poll composer UI and validation logic
damus/Features/Posting/Models/Post.swift Adds poll kind handling in event creation
damus/Features/Posting/Models/DraftsModel.swift Adds poll draft support to draft artifacts
damus/Features/Polls/Views/PollEventView.swift Implements poll display and voting UI
damus/Features/Polls/Views/PollComposerView.swift Implements poll creation interface
damus/Features/Polls/Models/PollVoteBuilder.swift Handles poll response event creation
damus/Features/Polls/Models/PollResultsStore.swift Manages poll state and vote submission
damus/Features/Polls/Models/PollModels.swift Defines poll domain models and parsing logic
damus/Features/Polls/Models/PollDraft.swift Defines poll draft structure for composition
damus/Features/Events/EventView.swift Adds poll event rendering support
damus/Core/Storage/DamusState.swift Integrates poll store into main app state
damus/Core/Nostr/NostrKind.swift Adds poll and poll_response event kinds
damus.xcodeproj/project.pbxproj Updates project file with new poll-related source files
DamusNotificationService/NotificationExtensionState.swift Adds poll store to notification extension state

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

func subscribe_to_home_filters(friends fs: [Pubkey]? = nil, relay_id: RelayURL? = nil) {
// TODO: separate likes?
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider grouping poll-related kinds together or adding a comment explaining the ordering rationale for better code organization.

Suggested change
// TODO: separate likes?
// TODO: separate likes?
// The ordering of kinds below is intentional for timeline display.
// Only one poll-related kind (.poll) exists currently; if more are added, group them together.

Copilot uses AI. Check for mistakes.

Comment on lines 124 to +181
func send_post() {
let new_post = build_post(state: self.damus_state, post: self.post, action: action, uploadedMedias: uploadedMedias, references: self.references, filtered_pubkeys: filtered_pubkeys)
let new_post = build_post(state: self.damus_state, post: self.post, action: action, uploadedMedias: uploadedMedias, references: self.references, filtered_pubkeys: filtered_pubkeys, pollDraft: pollDraft)
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This function call has many parameters. Consider creating a struct to encapsulate these parameters for better readability and maintainability.

Copilot uses AI. Check for mistakes.

// PollEventView.swift
// damus
//
// Created by ChatGPT on 2025-04-02.
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.

Suggested change
// Created by ChatGPT on 2025-04-02.
// Created by ChatGPT on 2024-04-02.

Copilot uses AI. Check for mistakes.

// PollComposerView.swift
// damus
//
// Created by ChatGPT on 2025-04-02.
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.

Suggested change
// Created by ChatGPT on 2025-04-02.
// Created by ChatGPT on 2024-04-02.

Copilot uses AI. Check for mistakes.

// PollVoteBuilder.swift
// damus
//
// Created by ChatGPT on 2025-04-02.
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.

Suggested change
// Created by ChatGPT on 2025-04-02.
// Created by ChatGPT on 2024-04-02.

Copilot uses AI. Check for mistakes.

// PollResultsStore.swift
// damus
//
// Created by ChatGPT on 2025-04-02.
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.

Suggested change
// Created by ChatGPT on 2025-04-02.
// Created by ChatGPT on 2024-06-10.

Copilot uses AI. Check for mistakes.

// PollModels.swift
// damus
//
// Created by ChatGPT on 2025-04-02.
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.

Suggested change
// Created by ChatGPT on 2025-04-02.
// Created by ChatGPT on 2024-06-10.

Copilot uses AI. Check for mistakes.

// PollDraft.swift
// damus
//
// Created by ChatGPT on 2025-04-02.
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.

Suggested change
// Created by ChatGPT on 2025-04-02.
// Created by ChatGPT on 2024-04-02.

Copilot uses AI. Check for mistakes.

alltheseas and others added 2 commits October 10, 2025 16:58
• Add unit tests
• Add poll rendering across timeline/profile flows
@alltheseas alltheseas changed the title Add NIP-88 polls support. Untested PR. Add NIP-88 polls support Oct 12, 2025
@alltheseas
Copy link
Collaborator Author

alltheseas commented Oct 12, 2025

In latsst commit I was able to

  1. create a nip-88 poll
  2. see a poll created by another nip-88 client
image image

@jb55
Copy link
Collaborator

jb55 commented Oct 12, 2025

note this is 100% pure vibe generated on a non-mac machine, and untested. will attempt testing now on xcode/macos

can you clarify what you mean by untested? does it work ?

@alltheseas
Copy link
Collaborator Author

The initial commit was untested as I produced the code on a Linux machine. Afterwards, I ported the PR to a macOS with Xcode.

The subsequent commits ensures that the build compiles and that polls events can be both generated, and seen.

I have confirmed that creating polls, and seeing polls, and responding to polls works on the latest commit.

The PR is ready for your review.

@alltheseas
Copy link
Collaborator Author

Yes, nip-88 polls worked for me on xcode iOS simulator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants